package org.example.deal;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class Test02 {

    public static void main(String[] args) {
        List<Trader> traderList = new ArrayList<>();
        traderList.add(new Trader("zhangsan", 100L, "zz"));
        traderList.add(new Trader("lisi", 300L, "zz"));
        traderList.add(new Trader("wangwu", 400L, "zz"));
        //取出交易额最大的交易员
        Trader value = traderList.stream()
                .max(new Comparator<Trader>() {
                    @Override
                    public int compare(Trader o1, Trader o2) {
                        return o1.getDeal().compareTo(o2.getDeal());
                    }
                }).orElse(new Trader("unkown", 0L, "unkown"));
        System.out.println(value);

        //17.找到交易额最小的交易
        Trader min = traderList.stream().min(Comparator.comparing(Trader::getDeal)).get();
        System.out.println(min);
    }
}
